<template>
<div>
    <van-nav-bar
  title="标题"
  left-text="地址"
  right-text="新增地址"
  left-arrow
  @click-left="onClickLeft"
  @click-right="onClickRight"
/>
      <div class="sty" v-for="(item,index) in addlist" :key="index">
        <p class="p1">{{item.address}} <van-icon name="records" class="p3"/></p>
        <p class="p2"><span>{{item.name}}</span> <span>{{item.phone}}</span></p>
      </div>
</div>
</template>

<script>
// 导入
import {api_address_list} from '../dmh/ulits/api'
export default {
    data(){
return{
    addlist:''
}
    },
    mounted(){
        // 发请求
        api_address_list({userid:localStorage.getItem('id')}).then((res)=>{
            for( var i =0;i<=res.data.list.length;i++){
            localStorage.setItem('addid'+i,res.data.list[i])
            }
         
            this.addlist= res.data.list
            console.log(res);
        })


    },
    methods:{
        // edit(item){
        //     this.$router.push('/bianji')

        // },
        onClickLeft(){
            // this.$router.go(-1)
            this.$router.push('/index/my')
        },

        onClickRight(){
            this.$router.push('/newhuo')
        }
    }

}
</script>

<style scoped>
.p3{
    float: right;
}
.p2{
    color: #ccc;
}
.p1{
    font-size: 20px;
    font-weight: 700;
}
.sty{
    margin: 0 auto;
    width: 80%;
    border-bottom: 1px solid gray;
}

</style>